from django.shortcuts import render
from repository import models



def home(request):
    return render(request, 'home/home.html')


# 技术博客
def technology_blog(request):
    return render(request, 'technology-blog/blog.html')


# 学习笔记、学员评价、如只邀约
def feedback_list(request, table):
    feedback_dict = {
        'learning-notes': {'banner': 'images/classmate-say/classmate-banner1.jpg', 'title': '学习笔记'},
        'student-evaluation': {'banner': 'images/classmate-say/classmate-banner2.jpg', 'title': '学员评价'},
        'work-invitation': {'banner': 'images/classmate-say/classmate-banner3.jpg', 'title': '入职邀约'},
    }

    return render(request, 'classmate-say/feedback.html', {'table': table,'banner': feedback_dict[table]['banner'], 'title': feedback_dict[table]['title']})

from rest_framework import generics
from web.serializers import FeedbackSerializer
from web.pagination import defaultPagination
# 过滤器
from django_filters.rest_framework import DjangoFilterBackend

class Ajax_feedback(generics.ListAPIView):

    queryset = models.Feedback.objects.all()

    # 序列化器
    serializer_class = FeedbackSerializer
    # 分页
    pagination_class = defaultPagination
    # 过滤
    filter_backends = [DjangoFilterBackend,]
    filter_fields = ['back_type'] # 过滤条件
